

#include "Losu_Std.h"
#include<iostream>
#include<string>
using namespace std;
extern "C"{
string rtstr; 
LNI_return rt;
LNI_return Els_STD_print(LNI_argv a){
    switch (a.type[3]){
        case ELS_TYPE_NUMBER:
            std::cout<<a.num[3]<<endl;
            break;
        case ELS_TYPE_STRING:
            std::cout<<a.str[3]<<endl;
            break; 
        default:
            break;
    }
    rt.type = ELS_TYPE_NULL; 
    return rt;
}
LNI_return Els_STD_input(LNI_argv a){
    cin>>rtstr;
    rt.type = ELS_TYPE_STRING;
    rt.str  = (char*)rtstr.c_str();
    return rt;
}
LNI_return Els_STD_lineinput(LNI_argv a){
    getline(cin,rtstr);
    rt.type = ELS_TYPE_STRING;
    rt.str  = (char*)rtstr.c_str();
    return rt;
}
LNI_return Els_STD_val(LNI_argv a){
    rt.type=ELS_TYPE_NUMBER;
    switch(a.type[3]){
        case ELS_TYPE_STRING:
            rt.num = atof(a.str[3]);
            break;
        case ELS_TYPE_NUMBER:
            rt.num = a.num[3];
            break;
        default :
            rt.num = 0;
            break; 
    }
    
    return rt;
}
LNI_return Els_STD_int(LNI_argv a){
    rt.type=ELS_TYPE_NUMBER;
    switch(a.type[3]){
        case ELS_TYPE_STRING:
            rt.num = (int)atof(a.str[3]);
            break;
        case ELS_TYPE_NUMBER:
            rt.num = (int)a.num[3];
            break;
        default :
            rt.num = 0;
            break; 
    }
    return rt;
}
LNI_return Els_STD_type(LNI_argv a){
    rt.type=ELS_TYPE_NUMBER;
    rt.num = a.type[3];
    return rt;
}
LNI_return Els_STD_exit(LNI_argv a){
    switch(a.type[3]){
        case ELS_TYPE_STRING:
            exit((int)atof(a.str[3]));
        case ELS_TYPE_NUMBER:
            exit(a.num[3]);
        default :
            exit(0);
    }
}
LNI_return ELs_STD_str(LNI_argv a){
    rt.type = ELS_TYPE_STRING;
    switch (a.type[3]){
        case ELS_TYPE_NUMBER:
            char s[10];gcvt(a.num[3],7,s);
            rtstr = s;
            break;
        case ELS_TYPE_STRING:
            rtstr = a.str[3];
            break;
    }
    rt.str = (char*)rtstr.c_str();
    return rt;
}
}